package com.soft2018;

public class Player {

    private Skill pskill;

    public Skill getPskill() {
        return pskill;
    }

    public void setPskill(Skill pskill) {
        this.pskill = pskill;
    }

    // 怪物名 字段名 小写
    private String name;

    // 起名，对数据赋值，赋值方法
    public void setName(String name){
        this.name = name;
    }

    // 取值方法
    public String getName() {
        return name;
    }

    // 血量
    private int hp;

    // 取值器
    public void setHp(int m_hp) {
        this.hp = m_hp;
    }

    // 赋值器
    public int getHp() {
        return hp;
    }

    // 攻击力
    private int ap;

    public void setAp(int m_ap) {
        this.ap = m_ap;
    }

    public int getAp() {
        return ap;
    }

    //构造函数，用来初始化类对象
    public Player(){
        super();
    }
    //带参数构造函数，也是用来初始化类对象
    public Player(String name,int hp,int ap)
    {
        super();
        this.name = name;
        this.ap = ap;
        this.hp = hp;
    }

    public Player(String name,int hp,int ap,Skill pskill)
    {
        super();
        this.name = name;
        this.ap = ap;
        this.hp = hp;
        this.pskill = pskill;
    }
    public Player(String name,int hp,int ap,int sap,String sinfo,String sname)
    {
        super();
        this.name = name;
        this.ap = ap;
        this.hp = hp;
        Skill pskill = new Skill(sap,sinfo,sname);
        this.pskill = pskill;
    }
    //TODO:书写一个 print 函数，打印当前对象的状态信息
    public void print(){
        System.out.println("玩家："+this.name+"当前血量："+this.hp+",当前攻击力:"+this.ap);
        if(this.pskill != null)
        {this.pskill.sprint();}
    }

    // 玩家攻击怪物方法
    // 参数是任意一个被玩家打的怪兽对象
    public void killMonster(Monster m)
    {
        m.dropHp(this.ap);
        System.out.println(this.name+"出招了，风云变色，一记重击击中"+m.getM_name() + "，怪物掉了"+this.ap+"血");
    }

    // 用技能攻击怪物
    public void skm(Monster m)
    {
        m.dropHp(this.pskill.getSap());
        System.out.println(this.name+"使出了："+this.pskill.getSname()+
                ","+this.pskill.getSinfo()+","+m.getM_name()+
                "掉了 "+this.pskill.getSap()+" 滴血");
    }
    public void dropHp(int attack)
    {
        this.hp -= attack;
    }

}
